<? 
	if(isset($_POST['btnsubmit']))
	{
		require("required/dbconnect.php");
		require("required/email.php");
		$bid=$_POST['bid'];
		$paymentdate=$_POST['paymentdate'];
		$paymentbank=$_POST['paymentbank'];
		$accountnumber=$_POST['accountnumber'];
		$paidamount=$_POST['paidamount'];
		$member_id=$_SESSION['admin_loginid'];
		$message=$_POST['message'];
		
		$insert=mysql_query("insert into os_payment_record (uid,bid,paymentdate,paymentbank,accountnumber,paidamount,message,create_datetime)
							values($member_id,$bid,'$paymentdate','$paymentbank','$accountnumber','$paidamount','$message',now())");
		
		$update=mysql_query("update os_bill_details set status=3 where id=$bid");
		$get_payment_id=mysql_query("select id from os_payment_record where uid=$member_id order by create_datetime desc limit 1");
		$payment_id=mysql_result($get_payment_id,0,"id");
		
		//email_payment_notice($bid,$payment_id);
		
		
		header("Location:order_viewfull.php?id=$bid");
	}
	
	require("required/dbconnect.php"); 
	require("required/function.php"); 
	require("required/header.php");
	
	
	
	$bid=$_GET['id'];
	
	$get_bill=mysql_query("select * from os_bill_details where id=$bid");
	if(mysql_num_rows($get_bill)==0)
	{
?>
		<script language="javascript">
			window.location="os_invalid.php";
		</script>
<?	
	}
	$b=mysql_fetch_array($get_bill,MYSQL_ASSOC);

	$get_item=mysql_query("select * from os_bill_items where bid=$bid")or die("line 11".mysql_error());
?>
<script language="javascript">
	function validatefrm1(frm1)
	{
		if(document.frm1.paymentbank.value=="")
		{
			alert("Please enter payment bank");
			document.frm1.paymentbank.focus();
			return false;
		}
		
		if(document.frm1.accountnumber.value=="")
		{
			alert("Please enter account number");
			document.frm1.accountnumber.focus();
			return false;
		}
		
		if(document.frm1.paidamount.value=="")
		{
			alert("Please enter paid amount");
			document.frm1.paidamount.focus();
			return false;
		}
		return true;
	
	}

</script>
<table width="100%">

	<Td valign="top">
		<table width="100%">
			<script type="text/javascript" src="../required/calendarDateInput.js"></script>		
			<form action="<?= $_SERVER['PHP_SELF'] ?>" name="frm1" method="post" onSubmit="return validatefrm1(this)">
			<tr>
				<td align="center">
					<table width="80%" class="solidborder">
						<tr>
							<td colspan="3"><strong>Please fill in payment information</strong></td>
						</tr>
						<tr>
							<td width="13%">Order number</td><td width="1%">:</td><td width="29%"><?= $b['invoice_number'] ?>	</td>
						</tr>
						<tr>
							<td width="13%">Order date</td><td width="1%">:</td><td width="29%"><?= $b['create_date'] ?></td>
						</tr>
						<tr>
							<td>Payment date</td><td width="1%">:</td><td><script>DateInput('paymentdate', true, 'YYYY-MM-DD')</script></td>
						</tr>
						<tr>
							<td>Bank</td><td width="1%">:</td><td><input type="text" size="20" name="paymentbank" class="text" maxlength="100"></td>
						</tr>
						<tr>
							<td>Reference Number</td><td width="1%">:</td><td><input type="text" size="20" name="accountnumber" class="text" maxlength="40"></td>
						</tr>
						<tr>
							<td>Paid amount</td><td width="1%">:</td><td><input type="text" size="20" name="paidamount" class="text" maxlength="10"></td>
						</tr>
						<tr valign="top">
							<td>Remark</td><td>:</td><td><input type="text" size="40" name="message" class="text" maxlength="100"> </td>
						</tr>
						<input type="hidden" value="<?= $bid ?>" name="bid">
						<tr>
						<td colspan="3" align="center"> <input type="submit" value="Submit" name="btnsubmit" class="button"> <input type="button" value="Back" class="button" onClick="history.go(-1)"></td>
						</tr>
					</table>
				</td>
			</tr>
			</form>
		</table>
				
		</Td>
	</tr>		  
	</table>

<? require("required/footer.php"); ?>	